package com.free.semantic.core.concept;

import com.free.semantic.core.ConceptInstanceManage;
import com.free.semantic.core.ConceptManage;
import com.free.semantic.core.concept.impl.ConceptSelfInfoConcept;
import com.free.semantic.core.concept.impl.ImplementRegisterConcept;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static com.free.semantic.core.concept.impl.ConceptSelfInfoConcept.keyConceptLs;
import static com.free.semantic.core.concept.impl.ConceptSelfInfoConcept.relationLs;

public class SubConceptManage {

    private static List<BaseConcept> getConceptList() {
        List<BaseConcept> concepts = new ArrayList<>();
        concepts.add(new ConceptSelfInfoConcept());
        concepts.add(new ImplementRegisterConcept());
        return concepts;
    }

    public static void appendSubConcept(ConceptManage conceptManage) {
        for (BaseConcept baseConcept : getConceptList()) {
            baseConcept.initConcept(conceptManage);
            baseConcept.initRelationDef(conceptManage);
        }
    }

    public static void appendSubConceptImpl(ConceptInstanceManage instanceManage) {
        for (BaseConcept baseConcept : getConceptList()) {
            baseConcept.initConceptImpl(instanceManage);
        }
    }

    private static Set<String> allConcept = null;

    private static Set<String> allRelationName = null;

    public static synchronized Set<String> getConceptLs() {
        if (allConcept == null) {
            HashSet<String> conceptLs = new HashSet<>(keyConceptLs);
            conceptLs.addAll(ImplementRegisterConcept.conceptLs);
            allConcept = conceptLs;
        }
        return allConcept;
    }

    public static synchronized Set<String> getRelationNameLs() {
        if (allRelationName == null) {
            HashSet<String> relationList = new HashSet<>(relationLs);
            relationList.addAll(ImplementRegisterConcept.relationLs);
            allRelationName = relationList;
        }
        return allRelationName;
    }


}
